package com.issue.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.issue.common.annotation.Log;
import com.issue.common.core.controller.BaseController;
import com.issue.common.core.domain.AjaxResult;
import com.issue.common.enums.BusinessType;
import com.issue.system.domain.ChildStatus;
import com.issue.system.service.IChildStatusService;
import com.issue.common.utils.poi.ExcelUtil;
import com.issue.common.core.page.TableDataInfo;

/**
 * Child StatusController
 * 
 * @author system
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/system/child_status")
public class ChildStatusController extends BaseController
{
    @Autowired
    private IChildStatusService childStatusService;

    /**
     * 查询Child Status列表
     */
    @PreAuthorize("@ss.hasPermi('system:child_status:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChildStatus childStatus)
    {
        startPage();
        List<ChildStatus> list = childStatusService.selectChildStatusList(childStatus);
        return getDataTable(list);
    }

    /**
     * 导出Child Status列表
     */
    @PreAuthorize("@ss.hasPermi('system:child_status:export')")
    @Log(title = "Child Status", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChildStatus childStatus)
    {
        List<ChildStatus> list = childStatusService.selectChildStatusList(childStatus);
        ExcelUtil<ChildStatus> util = new ExcelUtil<ChildStatus>(ChildStatus.class);
        util.exportExcel(response, list, "Child Status数据");
    }

    /**
     * 获取Child Status详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:child_status:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(childStatusService.selectChildStatusById(id));
    }

    /**
     * 新增Child Status
     */
    @PreAuthorize("@ss.hasPermi('system:child_status:add')")
    @Log(title = "Child Status", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChildStatus childStatus)
    {
        return toAjax(childStatusService.insertChildStatus(childStatus));
    }

    /**
     * 修改Child Status
     */
    @PreAuthorize("@ss.hasPermi('system:child_status:edit')")
    @Log(title = "Child Status", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChildStatus childStatus)
    {
        return toAjax(childStatusService.updateChildStatus(childStatus));
    }

    /**
     * 删除Child Status
     */
    @PreAuthorize("@ss.hasPermi('system:child_status:remove')")
    @Log(title = "Child Status", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(childStatusService.deleteChildStatusByIds(ids));
    }
}
